package transform;

import bean.SensorReading;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.junit.Test;

public class Flink_Transform_MaxBy {
    //TODO 最大温度
    @Test
    public void test() throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.readTextFile("input/sensor.txt").map(
                value -> {
                    String[] split = value.split(",");
                    return new SensorReading(split[0], Long.parseLong(split[1]), Double.parseDouble(split[2]));
                }
        ).keyBy(SensorReading::getId).maxBy("temp").print();
        env.execute();
    }
}
